package com.rustic.server.bean;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.format.NumberFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.HeadFontStyle;
import lombok.Data;

import java.util.Date;

/**
 * Excel导入导出模板类(示例)
 *
 *
 */
@Data
@ColumnWidth(12)
@HeadFontStyle(fontHeightInPoints = 14)
public class ExcelExample {

    /**
     * 最终生成效果:
     * |--------------------------------------------|
     * |       |                用户                 |
     * | 用户id |------------------------------------|
     * |       | 用户名 |         注册时间      | 年龄  |
     * |--------------------------------------------|
     * |   1   |  张三  | 2023-01-01 00:00:00 |  20  |
     * |--------------------------------------------|
     * |   2   |  李四  | 2023-01-01 00:00:00 |  21  |
     * |--------------------------------------------|
     */

    @ExcelProperty("用户id")
    private int id;

    @ExcelProperty({"用户", "用户名"})
    private String name;

    @ColumnWidth(18)
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    @ExcelProperty({"用户", "注册时间"})
    private Date date;

    @NumberFormat("#.##%")
    @ExcelProperty({"用户", "年龄"})
    private String age;

    @ExcelIgnore
    private String mobile;
}
